package com.pms.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.pms.entity.Contact;
import com.pms.entity.Document;

import com.pms.util.DBHelp;
import com.pms.util.RowMapper;

public class NewContactDao {
	DBHelp<Contact> db = new DBHelp<Contact>();
	public void save(Contact con) {
		String sql="INSERT INTO t_contact(`name`,company,mobile,tel,email,address,website,weibo,content,t_project_proid) VALUE(?,?,?,?,?,?,?,?,?,?)";
		db.executeSQL(sql,con.getName(),con.getCompany(),con.getMoblie(),con.getTel(),con.getEmail(),con.getAddress(),con.getWebsite(),con.getWeibo(),con.getContent(),con.getProject_id());
	}
	
	
	
	public List<Contact> findByProId(String proid) {
		String sql="SELECT id,`name` FROM t_contact WHERE `t_project_proid`=?";
		return db.executeQueryToList(sql,new RowMapper<Contact>(){
			public Contact mapRow(ResultSet rs) throws SQLException {
				Contact con = new Contact();
				con.setId((rs.getString("id")));
				con.setName((rs.getString("name")));
				return con;
			}
			
			
		}, proid);
	}

	
	
}
